﻿// Decompiled with JetBrains decompiler
// Type: DnProcessSimulateCommands.JointJog.CUiKinJointJogForm
// Assembly: DnProcessSimulateCommands, Version=2402.0.0.890, Culture=neutral, PublicKeyToken=null
// MVID: A885D881-AEDF-447E-852A-6F13102E089C
// Assembly location: C:\Program Files\Tecnomatix_2402\eMPower\DotNetCommands\DnProcessSimulateCommands.dll

using C1.Win.C1FlexGrid;
using C1.Win.C1FlexGrid.Util.BaseControls;
using DnProcessSimulateCommands.PoseEditor;
using EngineeringInternalExtension;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using Tecnomatix.Engineering;
using Tecnomatix.Engineering.PrivateImplementationDetails;
using Tecnomatix.Engineering.Ui;
using Tecnomatix.Engineering.Ui48;
using UiInternalControls.WindowsFormsControls;


namespace DnProcessSimulateCommands.JointJog;

public class CUiKinJointJogForm : TxForm
{
  private string m_poseName;
  private bool m_poseNameReadOnly;
  private TxPoseData m_initialPoseData;
  private List<CUiKinJointJogForm.CUiKinJointJogColumnData> m_columns = new List<CUiKinJointJogForm.CUiKinJointJogColumnData>();
  private List<TxFlexGridHostedControl> m_hostedControls = new List<TxFlexGridHostedControl>();
  private Dictionary<string, Column> m_columNameToColumn = new Dictionary<string, Column>();
  private CUiKinJointJogDeviceNodeData m_rootObjectData;
  private Dictionary<ITxObject, Row> m_componentToRowMap = new Dictionary<ITxObject, Row>();
  private Dictionary<TxFlexGridHostedControl, Row> m_hostedControlsToRowsMap = new Dictionary<TxFlexGridHostedControl, Row>();
  private Dictionary<ITxDevice, TxPoseData> m_externalDevicesToExternalDevicesInitialPoses = new Dictionary<ITxDevice, TxPoseData>();
  private CApKinJointJogApp m_jointJogApplication = new CApKinJointJogApp();
  private readonly string SteeringColumnName = JointJogStringTable.STEERING_COLUMN_NAME;
  private readonly string ValueColumnName = JointJogStringTable.VALUE_COLUMN_NAME;
  private readonly string LSLimitColumnName = JointJogStringTable.LOWER_SOFT_COLUMN_NAME;
  private readonly string USLimitColumnName = JointJogStringTable.UPPER_SOFT_COLUMN_NAME;
  private readonly string ColumnsVersion = "03";
  private bool m_okPressed;
  private bool m_newPoseMode;
  private bool m_okEnabled = true;
  private DialogResult m_closeDialogResult;
  private ToolTip m_tooltip;
  private IContainer components;
  private TxFlexGrid m_flexGrid;
  private TxToolStrip toolStrip1;
  private TxToolStripButton m_toolStripButtonOptions;
  private ToolStripSeparator toolStripSeparator1;
  private TxToolStripButton m_toolStripButtonResetSoftLimits;
  private Button m_buttonReset;
  private Button m_buttonOK;
  private Button m_buttonClose;
  private TxToolStripButton m_toolStripButtonDependentJoints;
  private TxToolStripButton m_toolStripButtonResetToHardLimits;
  private Label m_labelPoseName;
  private TextBox m_textBoxPoseName;

  public CUiKinJointJogForm()
  {
    this.InitializeComponent();
    this.BuildColumns();
    this.m_toolStripButtonOptions.SetImage(TxImageManager.GetImageByKey("Options"));
    this.m_toolStripButtonDependentJoints.SetImage(TxImageManager.GetImageByKey("ShowDependentJoints"));
    this.m_toolStripButtonResetToHardLimits.SetImage(TxImageManager.GetImageByKey("ResetSelectedLimitToHardLimits"));
    this.m_toolStripButtonResetSoftLimits.SetImage(TxImageManager.GetImageByKey("ResetAllLimitsToHardLimits"));
  }

  public string PoseName
  {
    get => this.m_poseName;
    set => this.m_poseName = value;
  }

  public bool PoseNameReadOnly
  {
    get => this.m_poseNameReadOnly;
    set => this.m_poseNameReadOnly = value;
  }

  public DialogResult CloseDialogResult => this.m_closeDialogResult;

  public bool OkEnabled
  {
    get => this.m_okEnabled;
    set => this.m_okEnabled = value;
  }

  public TxPose Pose { get; set; }

  public virtual void OnInitTxForm()
  {
    base.OnInitTxForm();
    this.AutoSizeForm();
  }

  public void Show(ITxDevice rootDevice)
  {
    this.InitFormData(rootDevice);
    this.InitTooltips();
    if (!this.CheckForOutOfLimitsJoints(rootDevice))
      return;
    this.m_buttonOK.Visible = false;
    this.m_buttonClose.Text = JointJogStringTable.CLOSE_CAPTION;
    this.m_buttonReset.Location = new Point(this.m_buttonClose.Location.X - (this.m_buttonReset.Width + 8), this.m_buttonReset.Location.Y);
    this.m_rootObjectData.UpdatePoseInPoseList();
    this.m_textBoxPoseName.SendToBack();
    this.m_labelPoseName.SendToBack();
    this.m_textBoxPoseName.Visible = false;
    this.m_labelPoseName.Visible = false;
    TxFlexGrid flexGrid = this.m_flexGrid;
    ((Control) flexGrid).Height = ((Control) flexGrid).Height + (this.m_textBoxPoseName.Bottom - ((Control) this.m_flexGrid).Bottom);
    ((Control) this).Show();
  }

  public DialogResult ShowDialog(ITxDevice rootDevice, TxPoseData poseData, string dialogTitle)
  {
    DialogResult dialogResult = DialogResult.None;
    if (this.InitInNewPoseMode(rootDevice, poseData, dialogTitle))
      dialogResult = ((Form) this).ShowDialog();
    return dialogResult;
  }

  public bool ShowModeless(ITxDevice rootDevice, TxPoseData poseData, string dialogTitle)
  {
    bool flag = false;
    if (this.InitInNewPoseMode(rootDevice, poseData, dialogTitle))
    {
      ((Control) this).Show();
      flag = true;
    }
    return flag;
  }

  private bool InitInNewPoseMode(ITxDevice rootDevice, TxPoseData poseData, string dialogTitle)
  {
    bool flag = false;
    this.m_newPoseMode = true;
    ((Control) this).Text = dialogTitle;
    this.InitFormData(rootDevice);
    this.InitTooltips();
    if (this.CheckForOutOfLimitsJoints(rootDevice))
    {
      this.m_rootObjectData.ChangeDevicePose(poseData);
      this.m_rootObjectData.UpdatePoseInPoseList();
      this.m_textBoxPoseName.Text = this.PoseName;
      this.m_textBoxPoseName.ReadOnly = this.PoseNameReadOnly && this.OkEnabled;
      this.m_buttonOK.Enabled = this.OkEnabled;
      this.m_textBoxPoseName.Select();
      this.m_textBoxPoseName.SelectAll();
      flag = true;
    }
    return flag;
  }

  public bool CheckForOutOfLimitsJoints(ITxDevice rootDevice)
  {
    bool flag = false;
    if (TxApplication.Options.Motion.LimitsCheck && this.m_jointJogApplication.AreOutOfLimitsJoints())
    {
      if (TxMessageBox.Show(string.Format(JointJogStringTable.OUT_OF_LIMITS_JOINTS_MESSAGE, (object) ((ITxObject) rootDevice).Name), JointJogStringTable.CMD_NAME, MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
      {
        this.m_jointJogApplication.TrimOutOfLimitsJoints();
        flag = true;
      }
    }
    else
      flag = true;
    return flag;
  }

  private void InitFormData(ITxDevice rootDevice, bool isReInit = false)
  {
    ((Control) this).Text = $"{JointJogStringTable.CMD_NAME} - {((ITxObject) rootDevice).Name}";
    this.m_rootObjectData = this.m_jointJogApplication.GetDeviceNodeData(rootDevice);
    this.m_initialPoseData = new TxPoseData(this.m_rootObjectData.Device.CurrentPose);
    this.AddNodeData((CUiKinJointJogNodeData) this.m_rootObjectData, 0);
    double? prismaticStepSizeValue;
    double? revoluteStepSizeValue;
    int? customSliderSensitivityValue;
    new CUiKinJointJogOptionsForm().LoadOptionsData(out prismaticStepSizeValue, out revoluteStepSizeValue, out customSliderSensitivityValue);
    if (prismaticStepSizeValue.HasValue && revoluteStepSizeValue.HasValue && customSliderSensitivityValue.HasValue)
      this.m_jointJogApplication.FireOptionsChanged((object) this, Convert.ToDouble(prismaticStepSizeValue.Value), Convert.ToDouble(revoluteStepSizeValue.Value), customSliderSensitivityValue.Value);
    this.SaveExternalJointsValues();
    if (isReInit)
      return;
    this.RegisterForEvents();
    this.InitGridStyles();
  }

  private void RegisterForEvents()
  {
    TxApplication.ActiveDocument.Selection.Cleared += new TxSelection_ClearedEventHandler(this.Selection_Cleared);
    TxApplication.ActiveDocument.Selection.ItemsAdded += new TxSelection_ItemsAddedEventHandler(this.Selection_ItemsAdded);
    TxApplication.ActiveDocument.Selection.ItemsRemoved += new TxSelection_ItemsRemovedEventHandler(this.Selection_ItemsRemoved);
    TxApplication.ActiveDocument.Selection.ItemsSet += new TxSelection_ItemsSetEventHandler(this.Selection_ItemsSet);
    TxApplication.ActiveDocument.Unloading += new TxDocument_UnloadingEventHandler(this.ActiveDocument_Unloading);
    this.m_jointJogApplication.LimitsControlsEntered += new CApKinJointJogApp.CUiKinJointJogJointLimitsControlsEnteredHandler(this.m_jointJogApplication_LimitsControlsEntered);
    this.m_jointJogApplication.LimitsControlsLeaved += new CApKinJointJogApp.CUiKinJointJogJointLimitsControlsLeavedHandler(this.m_jointJogApplication_LimitsControlsLeaved);
    this.RegisterForDeviceEvents(this.m_rootObjectData.Device);
    this.RegisterForExternalAxisDeleted(this.m_rootObjectData.Device);
    this.RegisterForExternalAxisEvents(this.m_rootObjectData.Device);
    TxApplication.Options.Units.LinearUnitsChanged += new TxUnitsOptions_LinearUnitsChangedEventHandler(this.Units_LinearUnitsChanged);
    TxApplication.Options.Units.AngularUnitsChanged += new TxUnitsOptions_AngularUnitsChangedEventHandler(this.Units_AngularUnitsChanged);
  }

  private void UnregisterFromEvents()
  {
    TxApplication.ActiveDocument.Selection.Cleared -= new TxSelection_ClearedEventHandler(this.Selection_Cleared);
    TxApplication.ActiveDocument.Selection.ItemsAdded -= new TxSelection_ItemsAddedEventHandler(this.Selection_ItemsAdded);
    TxApplication.ActiveDocument.Selection.ItemsRemoved -= new TxSelection_ItemsRemovedEventHandler(this.Selection_ItemsRemoved);
    TxApplication.ActiveDocument.Selection.ItemsSet -= new TxSelection_ItemsSetEventHandler(this.Selection_ItemsSet);
    TxApplication.ActiveDocument.Unloading -= new TxDocument_UnloadingEventHandler(this.ActiveDocument_Unloading);
    this.m_jointJogApplication.LimitsControlsEntered -= new CApKinJointJogApp.CUiKinJointJogJointLimitsControlsEnteredHandler(this.m_jointJogApplication_LimitsControlsEntered);
    this.m_jointJogApplication.LimitsControlsLeaved -= new CApKinJointJogApp.CUiKinJointJogJointLimitsControlsLeavedHandler(this.m_jointJogApplication_LimitsControlsLeaved);
    this.UnregisterFromDeviceEvents(this.m_rootObjectData.Device);
    this.UnregisterForExternalAxisDeleted(this.m_rootObjectData.Device);
    this.UnregisterForExternalAxisEvents(this.m_rootObjectData.Device);
    TxApplication.Options.Units.LinearUnitsChanged -= new TxUnitsOptions_LinearUnitsChangedEventHandler(this.Units_LinearUnitsChanged);
    TxApplication.Options.Units.AngularUnitsChanged -= new TxUnitsOptions_AngularUnitsChangedEventHandler(this.Units_AngularUnitsChanged);
  }

  private void RegisterForDeviceEvents(ITxDevice device)
  {
    ((ITxObject) device).Deleted += new TxObject_DeletedEventHandler(this.Device_Deleted);
    device.DeviceCompiled += new TxDevice_DeviceCompiledEventHandler(this.Device_DeviceCompiled);
    this.EnumerateDeviceDescendants(device, (Action<ITxDevice>) (childDevice =>
    {
      childDevice.DeviceCompiled += new TxDevice_DeviceCompiledEventHandler(this.Device_DeviceCompiled);
      ((ITxObject) childDevice).Deleted += new TxObject_DeletedEventHandler(this.Device_Deleted);
    }));
  }

  private void UnregisterFromDeviceEvents(ITxDevice device)
  {
    ((ITxObject) device).Deleted -= new TxObject_DeletedEventHandler(this.Device_Deleted);
    device.DeviceCompiled -= new TxDevice_DeviceCompiledEventHandler(this.Device_DeviceCompiled);
    this.EnumerateDeviceDescendants(device, (Action<ITxDevice>) (childDevice =>
    {
      childDevice.DeviceCompiled -= new TxDevice_DeviceCompiledEventHandler(this.Device_DeviceCompiled);
      ((ITxObject) childDevice).Deleted -= new TxObject_DeletedEventHandler(this.Device_Deleted);
    }));
  }

  private void RegisterForExternalAxisDeleted(ITxDevice rootDevice)
  {
    List<TxJoint> externalAxes = new List<TxJoint>();
    Action<ITxDevice> action = (Action<ITxDevice>) (device =>
    {
      if (!(device is ITxRobot robot2))
        return;
      foreach (TxJoint filterRemovedAx in (Collection<ITxObject>) this.m_jointJogApplication.FilterRemovedAxes(robot2))
      {
        if (!externalAxes.Contains(filterRemovedAx))
        {
          externalAxes.Add(filterRemovedAx);
          filterRemovedAx.Deleted += new TxObject_DeletedEventHandler(this.ExternalAxisJoint_Deleted);
        }
      }
    });
    action(rootDevice);
    this.EnumerateDeviceDescendants(rootDevice, action);
  }

  private void UnregisterForExternalAxisDeleted(ITxDevice rootDevice)
  {
    List<TxJoint> externalAxes = new List<TxJoint>();
    Action<ITxDevice> action = (Action<ITxDevice>) (device =>
    {
      if (!(device is ITxRobot robot2))
        return;
      foreach (TxJoint filterRemovedAx in (Collection<ITxObject>) this.m_jointJogApplication.FilterRemovedAxes(robot2))
      {
        if (!externalAxes.Contains(filterRemovedAx))
        {
          externalAxes.Add(filterRemovedAx);
          filterRemovedAx.Deleted -= new TxObject_DeletedEventHandler(this.ExternalAxisJoint_Deleted);
        }
      }
    });
    action(rootDevice);
    this.EnumerateDeviceDescendants(rootDevice, action);
  }

  private void RegisterForExternalAxisEvents(ITxDevice rootDevice)
  {
    if (!(rootDevice is ITxRobot itxRobot))
      return;
    itxRobot.ExternalAxisAdded += new TxRobot_ExternalAxisAddedEventHandler(this.Robot_ExternalAxisAdded);
    itxRobot.ExternalAxisRemoved += new TxRobot_ExternalAxisRemovedEventHandler(this.Robot_ExternalAxisRemoved);
  }

  private void UnregisterForExternalAxisEvents(ITxDevice rootDevice)
  {
    if (!(rootDevice is ITxRobot itxRobot))
      return;
    itxRobot.ExternalAxisAdded -= new TxRobot_ExternalAxisAddedEventHandler(this.Robot_ExternalAxisAdded);
    itxRobot.ExternalAxisRemoved -= new TxRobot_ExternalAxisRemovedEventHandler(this.Robot_ExternalAxisRemoved);
  }

  private void ExternalAxisJoint_Deleted(object sender, TxObject_DeletedEventArgs args)
  {
    TxJoint axis = sender as TxJoint;
    axis.Deleted -= new TxObject_DeletedEventHandler(this.ExternalAxisJoint_Deleted);
    this.m_jointJogApplication.AddAxisToRemove(axis);
    this.ResetViewContent();
  }

  private void Robot_ExternalAxisAdded(object sender, TxRobot_ExternalAxisAddedEventArgs args)
  {
    this.ResetViewContent();
  }

  private void Robot_ExternalAxisRemoved(object sender, TxRobot_ExternalAxisRemovedEventArgs args)
  {
    this.ResetViewContent();
  }

  private void EnumerateDeviceDescendants(ITxDevice device, Action<ITxDevice> action)
  {
    if (!(device is ITxObjectCollection objectCollection))
      return;
    TxTypeFilter txTypeFilter = new TxTypeFilter(typeof (ITxDevice));
    foreach (ITxDevice allDescendant in (Collection<ITxObject>) objectCollection.GetAllDescendants((ITxTypeFilter) txTypeFilter))
      action(allDescendant);
  }

  private void HandleSelection()
  {
    TxObjectList allItems = TxApplication.ActiveSelection.GetAllItems();
    if (((Collection<ITxObject>) allItems).Count != 1)
      return;
    ITxObject key = ((Collection<ITxObject>) allItems)[0];
    if (!this.m_componentToRowMap.ContainsKey(key))
      return;
    this.m_componentToRowMap[key].Node.EnsureVisible();
    this.m_componentToRowMap[key].Node.Select();
  }

  private void BuildColumns()
  {
    string str1 = (string) null;
    string str2 = (string) null;
    object obj;
    TxFormSettings.RestoreFormValue((Form) this, "Columns", ref obj);
    if (obj != null)
    {
      string str3 = obj as string;
      str2 = str3.Substring(0, 2);
      str1 = str3.Remove(0, 2);
    }
    if (str1 != null && str2 == this.ColumnsVersion)
    {
      string str4 = str1;
      char[] chArray = new char[1]{ '#' };
      foreach (string serializedString in str4.Split(chArray))
        this.m_columns.Add(CUiKinJointJogForm.CUiKinJointJogColumnData.DeserializeString(serializedString));
    }
    else
    {
      this.m_columns.Add(new CUiKinJointJogForm.CUiKinJointJogColumnData(this.SteeringColumnName, this.SteeringColumnName));
      this.m_columns.Add(new CUiKinJointJogForm.CUiKinJointJogColumnData(this.ValueColumnName, this.ValueColumnName));
      this.m_columns.Add(new CUiKinJointJogForm.CUiKinJointJogColumnData(this.LSLimitColumnName, JointJogStringTable.LOWER_SOFT_COLUMN_NICE_NAME));
      this.m_columns.Add(new CUiKinJointJogForm.CUiKinJointJogColumnData(this.USLimitColumnName, JointJogStringTable.UPPER_SOFT_COLUMN_NICE_NAME));
    }
    foreach (CUiKinJointJogForm.CUiKinJointJogColumnData column1 in this.m_columns)
    {
      Column column2 = ((C1FlexGridBase) this.m_flexGrid).Cols.Add();
      ((RowCol) column2).Visible = column1.Visible;
      column2.Name = column1.ColumnName;
      column2.Caption = column1.ColumnName;
      column2.AllowSorting = false;
      this.m_columNameToColumn.Add(column1.ColumnName, column2);
    }
  }

  private void InitGridStyles()
  {
    ((C1FlexGridBase) this.m_flexGrid).AutoSizeRow(0);
    ((C1FlexGridBase) this.m_flexGrid).AutoSizeCols();
    this.m_columNameToColumn[this.SteeringColumnName].Width = ((Control) new TxKinematicJointSlider()).Width + 5;
    this.m_columNameToColumn[this.ValueColumnName].Width = 65;
    ((RowCol) this.m_columNameToColumn[this.LSLimitColumnName]).TextAlign = (TextAlignEnum) 4;
    ((RowCol) this.m_columNameToColumn[this.USLimitColumnName]).TextAlign = (TextAlignEnum) 4;
    ((C1FlexGridBase) this.m_flexGrid).AutoSizeCol(((RowCol) ((C1FlexGridBase) this.m_flexGrid).Cols[this.LSLimitColumnName]).Index);
    ((C1FlexGridBase) this.m_flexGrid).AutoSizeCol(((RowCol) ((C1FlexGridBase) this.m_flexGrid).Cols[this.USLimitColumnName]).Index);
  }

  private void InitTooltips()
  {
    this.m_tooltip = new ToolTip();
    this.m_tooltip.AutoPopDelay = 5000;
    this.m_tooltip.InitialDelay = 1000;
    this.m_tooltip.ReshowDelay = 500;
    this.m_tooltip.ShowAlways = true;
  }

  private bool ShouldAddThisJoint(CUiKinJointJogNodeData jointData)
  {
    bool flag = true;
    if (TxFeatureManager.CheckFeature("USER_FORWARD"))
    {
      string niceName = jointData.NiceName;
      if (niceName.Contains("Platform") || niceName.Contains("AxisDistance") || niceName.Contains("Elbow") || niceName.Contains("LowerArmAux") || niceName.Contains("Telescope"))
        flag = false;
    }
    return flag;
  }

  private void AddNodeData(CUiKinJointJogNodeData nodeData, int level)
  {
    if (!this.ShouldAddThisJoint(nodeData))
      return;
    int count = ((RowColCollection) ((C1FlexGridBase) this.m_flexGrid).Rows).Count;
    Node node = ((C1FlexGridBase) this.m_flexGrid).Rows.InsertNode(count, level);
    node.Data = (object) nodeData.NiceName;
    node.Image = nodeData.NodeIcon;
    node.Key = (object) nodeData;
    nodeData.GridRow = node.Row;
    CUiKinJointJogJointNodeData jogJointNodeData = nodeData as CUiKinJointJogJointNodeData;
    CUiKinJointJogDeviceNodeData jogDeviceNodeData = nodeData as CUiKinJointJogDeviceNodeData;
    CUiKinJointJogComponentNodeData componentNodeData = nodeData as CUiKinJointJogComponentNodeData;
    if (jogJointNodeData != null)
    {
      TxFlexGridHostedControl key1 = new TxFlexGridHostedControl((ITxFlexGrid) this.m_flexGrid, (Control) jogJointNodeData.SliderControl, count, ((RowCol) this.m_columNameToColumn[this.SteeringColumnName]).Index, this.GetNextTabIndex(), false);
      this.m_hostedControls.Add(key1);
      this.m_hostedControlsToRowsMap.Add(key1, node.Row);
      TxFlexGridHostedControl key2 = new TxFlexGridHostedControl((ITxFlexGrid) this.m_flexGrid, (Control) jogJointNodeData.ValueControl, count, ((RowCol) this.m_columNameToColumn[this.ValueColumnName]).Index, this.GetNextTabIndex(), true);
      this.m_hostedControls.Add(key2);
      this.m_hostedControlsToRowsMap.Add(key2, node.Row);
      TxFlexGridHostedControl key3 = new TxFlexGridHostedControl((ITxFlexGrid) this.m_flexGrid, (Control) jogJointNodeData.LowSoftLimitControl, count, ((RowCol) this.m_columNameToColumn[this.LSLimitColumnName]).Index, this.GetNextTabIndex(), true);
      this.m_hostedControls.Add(key3);
      this.m_hostedControlsToRowsMap.Add(key3, node.Row);
      TxFlexGridHostedControl key4 = new TxFlexGridHostedControl((ITxFlexGrid) this.m_flexGrid, (Control) jogJointNodeData.UpperSoftLimitControl, count, ((RowCol) this.m_columNameToColumn[this.USLimitColumnName]).Index, this.GetNextTabIndex(), true);
      this.m_hostedControls.Add(key4);
      this.m_hostedControlsToRowsMap.Add(key4, node.Row);
      jogJointNodeData.JointValue = jogJointNodeData.Joint.CurrentValue;
      ((C1FlexGridBase) this.m_flexGrid).Rows[count].Height = ((Control) jogJointNodeData.ValueControl).Height;
      if (!jogJointNodeData.Joint.IsDependent)
        return;
      ((RowCol) node.Row).Visible = ((ToolStripButton) this.m_toolStripButtonDependentJoints).Checked;
    }
    else if (jogDeviceNodeData != null)
    {
      this.m_componentToRowMap.Add(jogDeviceNodeData.NodeObject, node.Row);
      TxFlexGridHostedControl key = new TxFlexGridHostedControl((ITxFlexGrid) this.m_flexGrid, (Control) jogDeviceNodeData.PosesListControl, count, ((RowCol) this.m_columNameToColumn[this.SteeringColumnName]).Index, this.GetNextTabIndex(), true);
      this.m_hostedControls.Add(key);
      this.m_hostedControlsToRowsMap.Add(key, node.Row);
      ((C1FlexGridBase) this.m_flexGrid).Rows[count].Height = jogDeviceNodeData.PosesListControl.Height;
      ((C1FlexGridBase) this.m_flexGrid).SetCellStyle(count, ((RowCol) this.m_columNameToColumn[this.LSLimitColumnName]).Index, ((C1FlexGridBase) this.m_flexGrid).Styles.Fixed);
      ((C1FlexGridBase) this.m_flexGrid).SetCellStyle(count, ((RowCol) this.m_columNameToColumn[this.USLimitColumnName]).Index, ((C1FlexGridBase) this.m_flexGrid).Styles.Fixed);
      ((C1FlexGridBase) this.m_flexGrid).SetCellStyle(count, ((RowCol) this.m_columNameToColumn[this.ValueColumnName]).Index, ((C1FlexGridBase) this.m_flexGrid).Styles.Fixed);
      TxComponentStructureTypeEnum componentStructureType = TxEngineeringDataInternal.GetComponentStructureType((ITxObject) jogDeviceNodeData.Device);
      foreach (CUiKinJointJogNodeData childrenNode in jogDeviceNodeData.ChildrenNodes)
      {
        if (componentStructureType != null)
          this.AddNodeData(childrenNode, level + 1);
        else if (childrenNode is CUiKinJointJogJointNodeData)
          this.AddNodeData(childrenNode, level + 1);
      }
    }
    else
    {
      if (componentNodeData == null)
        return;
      this.m_componentToRowMap.Add((ITxObject) componentNodeData.NodeObject, node.Row);
      ((C1FlexGridBase) this.m_flexGrid).Rows[count].Height = componentNodeData.NodeIcon.Height + 5;
      ((C1FlexGridBase) this.m_flexGrid).SetCellStyle(count, ((RowCol) this.m_columNameToColumn[this.SteeringColumnName]).Index, ((C1FlexGridBase) this.m_flexGrid).Styles.Fixed);
      ((C1FlexGridBase) this.m_flexGrid).SetCellStyle(count, ((RowCol) this.m_columNameToColumn[this.LSLimitColumnName]).Index, ((C1FlexGridBase) this.m_flexGrid).Styles.Fixed);
      ((C1FlexGridBase) this.m_flexGrid).SetCellStyle(count, ((RowCol) this.m_columNameToColumn[this.USLimitColumnName]).Index, ((C1FlexGridBase) this.m_flexGrid).Styles.Fixed);
      ((C1FlexGridBase) this.m_flexGrid).SetCellStyle(count, ((RowCol) this.m_columNameToColumn[this.ValueColumnName]).Index, ((C1FlexGridBase) this.m_flexGrid).Styles.Fixed);
      TxComponentStructureTypeEnum componentStructureType = TxEngineeringDataInternal.GetComponentStructureType((ITxObject) componentNodeData.NodeObject);
      foreach (CUiKinJointJogNodeData childrenNode in componentNodeData.ChildrenNodes)
      {
        if (componentStructureType != null)
          this.AddNodeData(childrenNode, level + 1);
        else if (childrenNode is CUiKinJointJogJointNodeData)
          this.AddNodeData(childrenNode, level + 1);
      }
    }
  }

  private int GetNextTabIndex()
  {
    int nextTabIndex = ((Control) this.m_flexGrid).TabIndex + 1;
    if (this.m_hostedControls.Count > 0)
      nextTabIndex = this.m_hostedControls[this.m_hostedControls.Count - 1].TabIndex + 1;
    return nextTabIndex;
  }

  private void AutoSizeForm()
  {
    ((Control) this.m_flexGrid).Resize -= new EventHandler(this.m_flexGrid_Resize);
    Rectangle displayRectangle1 = ((Control) this).DisplayRectangle;
    int height1 = displayRectangle1.Height;
    displayRectangle1 = ((Control) this.m_flexGrid).DisplayRectangle;
    int bottom = displayRectangle1.Bottom;
    int num1 = height1 - bottom;
    Rectangle displayRectangle2 = ((Control) this).DisplayRectangle;
    int width1 = displayRectangle2.Width;
    displayRectangle2 = ((Control) this.m_flexGrid).DisplayRectangle;
    int right = displayRectangle2.Right;
    int num2 = width1 - right;
    switch (((ScrollableControl) this.m_flexGrid).ScrollBarsVisible)
    {
      case ScrollBars.Horizontal:
        num1 -= SystemInformation.VerticalScrollBarWidth;
        break;
      case ScrollBars.Vertical:
        num2 -= SystemInformation.HorizontalScrollBarHeight;
        break;
      case ScrollBars.Both:
        num1 -= SystemInformation.VerticalScrollBarWidth;
        num2 -= SystemInformation.HorizontalScrollBarHeight;
        break;
    }
    int width2 = ((Control) this).Width;
    Rectangle rectangle = ((Control) this).DisplayRectangle;
    int width3 = rectangle.Width;
    int num3 = width2 - width3;
    int height2 = ((Control) this).Height;
    rectangle = ((Control) this).DisplayRectangle;
    int height3 = rectangle.Height;
    int num4 = height2 - height3;
    int num5 = num2 + num3;
    int num6 = num1 + num4;
    rectangle = Screen.PrimaryScreen.WorkingArea;
    int width4 = rectangle.Width / 3;
    if (((RowColCollection) ((C1FlexGridBase) this.m_flexGrid).Cols).Count > 0)
      width4 = ((C1FlexGridBase) this.m_flexGrid).Cols[((RowColCollection) ((C1FlexGridBase) this.m_flexGrid).Cols).Count - 1].Right + num5;
    rectangle = Screen.PrimaryScreen.WorkingArea;
    int height4 = rectangle.Height / 3;
    if (((RowColCollection) ((C1FlexGridBase) this.m_flexGrid).Rows).Count > 0)
      height4 = ((C1FlexGridBase) this.m_flexGrid).Rows[((RowColCollection) ((C1FlexGridBase) this.m_flexGrid).Rows).Count - 1].Bottom + num6;
    int width5 = width4;
    int height5 = height4;
    Size size1 = new Size(width4, height4);
    Size size2 = new Size(width5, height5);
    if (TxScreenUtilsEx.HasSingleScreen)
    {
      int num7 = ((Control) this).Left + width4;
      rectangle = Screen.PrimaryScreen.WorkingArea;
      int width6 = rectangle.Width;
      if (num7 > width6)
        height4 += SystemInformation.HorizontalScrollBarHeight;
      int num8 = ((Control) this).Top + height4;
      rectangle = Screen.PrimaryScreen.WorkingArea;
      int height6 = rectangle.Height;
      if (num8 > height6)
        width4 += SystemInformation.VerticalScrollBarWidth;
      int num9 = ((Control) this).Left + width4;
      rectangle = Screen.PrimaryScreen.WorkingArea;
      int width7 = rectangle.Width;
      if (num9 > width7)
      {
        rectangle = Screen.PrimaryScreen.WorkingArea;
        width4 = rectangle.Width - ((Control) this).Left;
      }
      int num10 = ((Control) this).Top + height4;
      rectangle = Screen.PrimaryScreen.WorkingArea;
      int height7 = rectangle.Height;
      if (num10 > height7)
      {
        rectangle = Screen.PrimaryScreen.WorkingArea;
        height4 = rectangle.Height - ((Control) this).Top;
      }
      size2.Width = width5 < width4 ? width4 : width5;
      size2.Height = height5 < height4 ? height4 : height5;
    }
    else
      TxScreenUtilsEx.GetFormMaxSize((Form) this, size1, ref size2);
    ((Control) this).MaximumSize = new Size(size2.Width + 50, size2.Height + 50);
    ((Form) this).Size = new Size(width4, height4);
    ((Control) this.m_flexGrid).Resize += new EventHandler(this.m_flexGrid_Resize);
  }

  private List<CUiKinJointJogForm.CUiKinJointJogColumnData> GetColumnsFromUI()
  {
    List<CUiKinJointJogForm.CUiKinJointJogColumnData> columnsFromUi = new List<CUiKinJointJogForm.CUiKinJointJogColumnData>();
    foreach (Column col in (IEnumerable) ((C1FlexGridBase) this.m_flexGrid).Cols)
    {
      foreach (CUiKinJointJogForm.CUiKinJointJogColumnData column in this.m_columns)
      {
        if (col.Name == column.ColumnName)
          columnsFromUi.Add(column);
      }
    }
    return columnsFromUi;
  }

  private void SaveExternalJointsValues()
  {
    foreach (Row row in (IEnumerable) ((C1FlexGridBase) this.m_flexGrid).Rows)
    {
      if (row.IsNode && row.Node.Key is CUiKinJointJogJointNodeData key && key.IsExternalJoint() && !this.m_externalDevicesToExternalDevicesInitialPoses.ContainsKey(key.Joint.Device))
        this.m_externalDevicesToExternalDevicesInitialPoses.Add(key.Joint.Device, new TxPoseData(key.Joint.Device.CurrentPose));
    }
  }

  private void RestoreExternalJointsValues()
  {
    foreach (ITxDevice key in this.m_externalDevicesToExternalDevicesInitialPoses.Keys)
      key.CurrentPose = this.m_externalDevicesToExternalDevicesInitialPoses[key];
  }

  private void ResetViewContent()
  {
    ((Control) this.m_flexGrid).Controls.Clear();
    ((C1FlexGridBase) this.m_flexGrid).Rows.RemoveRange(((RowColCollection) ((C1FlexGridBase) this.m_flexGrid).Rows).Fixed, ((RowColCollection) ((C1FlexGridBase) this.m_flexGrid).Rows).Count - ((RowColCollection) ((C1FlexGridBase) this.m_flexGrid).Rows).Fixed);
    this.m_jointJogApplication.DisposeNodeData();
    this.m_jointJogApplication.ResetDeviceMap();
    this.m_hostedControls = new List<TxFlexGridHostedControl>();
    this.m_hostedControlsToRowsMap = new Dictionary<TxFlexGridHostedControl, Row>();
    this.m_componentToRowMap = new Dictionary<ITxObject, Row>();
    this.m_externalDevicesToExternalDevicesInitialPoses = new Dictionary<ITxDevice, TxPoseData>();
    this.InitFormData(this.m_rootObjectData.Device, true);
    this.AutoSizeForm();
  }

  private void Device_DeviceCompiled(object sender, TxDevice_DeviceCompiledEventArgs args)
  {
    int num = (int) TxMessageBox.Show(JointJogStringTable.JOINT_JOG_DIALOG_WILL_CLOSE, ((Control) this).Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
    ((Form) this).Close();
  }

  private void Device_Deleted(object sender, TxObject_DeletedEventArgs args)
  {
    ((Form) this).Close();
  }

  private void m_jointJogApplication_LimitsControlsEntered(object sender, EventArgs args)
  {
    ((ToolStripItem) this.m_toolStripButtonResetToHardLimits).Enabled = true;
  }

  private void m_jointJogApplication_LimitsControlsLeaved(object sender, EventArgs args)
  {
    ((ToolStripItem) this.m_toolStripButtonResetToHardLimits).Enabled = false;
  }

  private void m_flexGrid_AfterCollapse(object sender, RowColEventArgs e)
  {
    ((Control) this.m_flexGrid).SuspendLayout();
    ((ScrollableControl) this.m_flexGrid).BeginUpdate();
    foreach (Row row in (IEnumerable) ((C1FlexGridBase) this.m_flexGrid).Rows)
    {
      if (row.IsNode && row.Node.Key is CUiKinJointJogJointNodeData key && !((ToolStripButton) this.m_toolStripButtonDependentJoints).Checked)
      {
        bool flag = ((RowCol) row).Visible && !key.Joint.IsDependent;
        if (((RowCol) row).Visible != flag)
          ((RowCol) row).Visible = flag;
      }
    }
    ((ScrollableControl) this.m_flexGrid).EndUpdate();
    ((Control) this.m_flexGrid).ResumeLayout();
    this.AutoSizeForm();
  }

  private void ActiveDocument_Unloading(object sender, TxDocument_UnloadingEventArgs args)
  {
    ((Form) this).Close();
  }

  protected virtual void OnClosing(CancelEventArgs e)
  {
    if (this.m_newPoseMode)
    {
      bool flag1 = CApKinPoseEditorApp.IsUniquePoseName(this.m_rootObjectData.Device, this.m_textBoxPoseName.Text);
      if (this.m_poseName == this.m_textBoxPoseName.Text)
        flag1 = true;
      bool flag2 = !this.m_newPoseMode || !this.m_okPressed | flag1;
      e.Cancel = !flag2;
      if (flag2)
      {
        this.m_closeDialogResult = this.m_okPressed ? DialogResult.OK : DialogResult.Cancel;
        this.m_poseName = this.m_okPressed ? this.m_textBoxPoseName.Text : (string) null;
        this.UnregisterFromEvents();
        base.OnClosing(e);
      }
      else
      {
        this.m_okPressed = false;
        int num = (int) TxMessageBox.Show(JointJogStringTable.EXISTING_POSE_NAME, ((Control) this).Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
        this.m_textBoxPoseName.Focus();
        this.m_textBoxPoseName.SelectAll();
      }
    }
    else
    {
      this.UnregisterFromEvents();
      base.OnClosing(e);
    }
  }

  protected virtual void OnFormClosed(FormClosedEventArgs e)
  {
    // ISSUE: explicit non-virtual call
    __nonvirtual (((Form) this).OnFormClosed(e));
    this.m_jointJogApplication.DisposeNodeData();
  }

  private void m_flexGrid_Paint(object sender, PaintEventArgs e)
  {
    foreach (TxFlexGridHostedControl hostedControl in this.m_hostedControls)
    {
      if (((RowCol) this.m_hostedControlsToRowsMap[hostedControl]).Visible)
        hostedControl.UpdatePosition();
      else
        hostedControl.Visible = false;
    }
  }

  private void m_flexGrid_MouseMove(object sender, EventArgs e)
  {
    int mouseCol = ((C1FlexGridBase) this.m_flexGrid).MouseCol;
    int mouseRow = ((C1FlexGridBase) this.m_flexGrid).MouseRow;
    bool flag = false;
    if (mouseCol >= 0 && mouseCol < ((RowColCollection) ((C1FlexGridBase) this.m_flexGrid).Cols).Count && mouseRow >= ((RowColCollection) ((C1FlexGridBase) this.m_flexGrid).Rows).Fixed && mouseRow < ((RowColCollection) ((C1FlexGridBase) this.m_flexGrid).Rows).Count && mouseCol == 0 && ((C1FlexGridBase) this.m_flexGrid).Rows[mouseRow] != null && ((C1FlexGridBase) this.m_flexGrid).Rows[mouseRow].Node != null && ((C1FlexGridBase) this.m_flexGrid).Rows[mouseRow].Node.Key != null && ((C1FlexGridBase) this.m_flexGrid).Rows[mouseRow].Node.Key is CUiKinJointJogJointNodeData key)
    {
      flag = true;
      string str = key.TooltipText;
      if (!this.m_tooltip.Active)
        this.m_tooltip.Active = true;
      if (!string.IsNullOrEmpty(str))
      {
        using (Graphics graphics = ((Control) this.m_flexGrid).CreateGraphics())
        {
          int num1 = (int) graphics.MeasureString(str, ((Control) this.m_flexGrid).Font).Width / (Screen.PrimaryScreen.Bounds.Width / 2);
          int num2 = str.Length / (num1 + 1);
          if (num1 > 0)
          {
            for (int index = 0; index < num1; ++index)
              str = str.Insert((index + 1) * num2, Environment.NewLine);
          }
        }
      }
      this.m_tooltip.SetToolTip((Control) this.m_flexGrid, str);
    }
    if (!this.m_tooltip.Active || flag)
      return;
    this.m_tooltip.Active = false;
  }

  private void m_toolStripButtonOptions_Click(object sender, EventArgs e)
  {
    CUiKinJointJogOptionsForm jointJogOptionsForm = new CUiKinJointJogOptionsForm();
    this.m_columns = this.GetColumnsFromUI();
    if (jointJogOptionsForm.ShowDialog(this.m_columns) != DialogResult.OK)
      return;
    this.m_columns = jointJogOptionsForm.DialogData.Columns;
    for (int index = 0; index < jointJogOptionsForm.DialogData.Columns.Count; ++index)
    {
      CUiKinJointJogForm.CUiKinJointJogColumnData column1 = jointJogOptionsForm.DialogData.Columns[index];
      Column column2 = this.m_columNameToColumn[column1.ColumnName];
      ((RowCol) column2).Move(index + 1);
      ((RowCol) column2).Visible = column1.Visible;
    }
    string str = this.ColumnsVersion;
    foreach (CUiKinJointJogForm.CUiKinJointJogColumnData column in this.m_columns)
      str = $"{str}{column.SerializeData()}#";
    TxFormSettings.StoreFormValue((Form) this, "Columns", (object) str.TrimEnd('#'));
    this.m_jointJogApplication.FireOptionsChanged(sender, jointJogOptionsForm.DialogData.PrismaticStepSize, jointJogOptionsForm.DialogData.RevoluteStepSize, jointJogOptionsForm.DialogData.CustomSliderSensitivity);
    this.AutoSizeForm();
    ((Control) this.m_flexGrid).Refresh();
  }

  private void m_textBoxPoseName_TextChanged(object sender, EventArgs e)
  {
    this.m_buttonOK.Enabled = !string.IsNullOrEmpty(this.m_textBoxPoseName.Text) && this.OkEnabled;
  }

  private void m_buttonApply_Click(object sender, EventArgs e)
  {
    if (!this.m_buttonOK.Focused)
      this.m_buttonOK.Focus();
    this.m_okPressed = true;
    if (!this.m_newPoseMode)
      return;
    ((Form) this).Close();
  }

  private void m_toolStripButtonResetSoftLimits_Click(object sender, EventArgs e)
  {
    this.m_jointJogApplication.ResetSoftLimits();
    TxApplication.RefreshDisplay();
  }

  private void m_toolStripButtonResetToHardLimits_Click(object sender, EventArgs e)
  {
    foreach (Row row in (IEnumerable) ((C1FlexGridBase) this.m_flexGrid).Rows)
    {
      if (row.IsNode && row.Node.Key is CUiKinJointJogJointNodeData key)
      {
        if (((Control) key.LowSoftLimitControl).Focused)
        {
          key.ResetToLowerHardLimits();
          break;
        }
        if (((Control) key.UpperSoftLimitControl).Focused)
        {
          key.ResetToUpperHardLimits();
          break;
        }
      }
    }
  }

  private void m_toolStripButtonDependentJoints_Click(object sender, EventArgs e)
  {
    ((ToolStripButton) this.m_toolStripButtonDependentJoints).Checked = !((ToolStripButton) this.m_toolStripButtonDependentJoints).Checked;
    ((Control) this.m_flexGrid).SuspendLayout();
    ((ScrollableControl) this.m_flexGrid).BeginUpdate();
    foreach (Row row in (IEnumerable) ((C1FlexGridBase) this.m_flexGrid).Rows)
    {
      if (row.IsNode)
      {
        bool flag1 = true;
        Node node = row.Node.GetNode((NodeTypeEnum) 1);
        if (node != null)
          flag1 = node.Expanded;
        if (row.Node.Key is CUiKinJointJogJointNodeData key)
        {
          if (((ToolStripButton) this.m_toolStripButtonDependentJoints).Checked)
          {
            ((ToolStripItem) this.m_toolStripButtonDependentJoints).Text = ((ToolStripItem) this.m_toolStripButtonDependentJoints).Text.Replace(JointJogStringTable.SHOW_TEXT, JointJogStringTable.HIDE_TEXT);
            if (((RowCol) row).Visible != flag1)
              ((RowCol) row).Visible = flag1;
          }
          else
          {
            ((ToolStripItem) this.m_toolStripButtonDependentJoints).Text = ((ToolStripItem) this.m_toolStripButtonDependentJoints).Text.Replace(JointJogStringTable.HIDE_TEXT, JointJogStringTable.SHOW_TEXT);
            bool flag2 = flag1 && !key.Joint.IsDependent;
            if (((RowCol) row).Visible != flag2)
              ((RowCol) row).Visible = flag2;
          }
          ((ToolStripItem) this.m_toolStripButtonDependentJoints).ToolTipText = ((ToolStripItem) this.m_toolStripButtonDependentJoints).Text;
        }
      }
    }
    ((ScrollableControl) this.m_flexGrid).EndUpdate();
    ((Control) this.m_flexGrid).ResumeLayout();
    this.AutoSizeForm();
  }

  private void m_buttonClose_Click(object sender, EventArgs e) => ((Form) this).Close();

  private void m_flexGrid_Resize(object sender, EventArgs e) => ((Control) this).Refresh();

  private void m_flexGrid_AfterResizeColumn(object sender, RowColEventArgs e)
  {
    this.AutoSizeForm();
  }

  private void m_flexGrid_AfterScroll(object sender, RangeEventArgs e)
  {
    this.m_jointJogApplication.RefreshAllControls();
  }

  private void m_buttonReset_Click(object sender, EventArgs e)
  {
    try
    {
      this.m_jointJogApplication.ResetSoftLimitsToInitialValues();
      this.m_rootObjectData.Device.CurrentPose = this.m_initialPoseData;
      this.RestoreExternalJointsValues();
      if (TxApplication.Options.Motion.LimitsCheck)
        this.m_jointJogApplication.TrimOutOfLimitsJoints();
      this.m_jointJogApplication.RefreshAllControls();
      TxGraphicViewerEx.RequireRefreshSynchronization();
      TxApplication.RefreshDisplay();
    }
    catch (Exception ex)
    {
      TxApplication.LogWriter.WriteExceptionLine(ex);
      int num = (int) TxMessageBox.Show(JointJogStringTable.DEVICE_RESET_ERROR_MESSAGE, ((Control) this).Text, MessageBoxButtons.OK, MessageBoxIcon.Hand);
    }
  }

  private void Selection_ItemsSet(object sender, TxSelection_ItemsSetEventArgs args)
  {
    this.HandleSelection();
  }

  private void Selection_ItemsRemoved(object sender, TxSelection_ItemsRemovedEventArgs args)
  {
    this.HandleSelection();
  }

  private void Selection_ItemsAdded(object sender, TxSelection_ItemsAddedEventArgs args)
  {
    this.HandleSelection();
  }

  private void Selection_Cleared(object sender, TxSelection_ClearedEventArgs args)
  {
    this.HandleSelection();
  }

  private void Units_AngularUnitsChanged(
    object sender,
    TxUnitsOptions_AngularUnitsChangedEventArgs args)
  {
    this.ResetViewContent();
  }

  private void Units_LinearUnitsChanged(
    object sender,
    TxUnitsOptions_LinearUnitsChangedEventArgs args)
  {
    this.ResetViewContent();
  }

  protected virtual void Dispose(bool disposing)
  {
    if (disposing && this.components != null)
      this.components.Dispose();
    base.Dispose(disposing);
  }

  private void InitializeComponent()
  {
    ComponentResourceManager componentResourceManager = new ComponentResourceManager(typeof (CUiKinJointJogForm));
    this.m_flexGrid = new TxFlexGrid();
    this.toolStrip1 = new TxToolStrip();
    this.m_toolStripButtonOptions = new TxToolStripButton();
    this.m_toolStripButtonDependentJoints = new TxToolStripButton();
    this.toolStripSeparator1 = new ToolStripSeparator();
    this.m_toolStripButtonResetToHardLimits = new TxToolStripButton();
    this.m_toolStripButtonResetSoftLimits = new TxToolStripButton();
    this.m_buttonReset = new Button();
    this.m_buttonOK = new Button();
    this.m_buttonClose = new Button();
    this.m_labelPoseName = new Label();
    this.m_textBoxPoseName = new TextBox();
    ((ISupportInitialize) this.m_flexGrid).BeginInit();
    ((Control) this.toolStrip1).SuspendLayout();
    this.toolStrip1.ClickThrough = true;
    ((Control) this).SuspendLayout();
    ((C1FlexGridBase) this.m_flexGrid).AllowEditing = false;
    componentResourceManager.ApplyResources((object) this.m_flexGrid, "m_flexGrid");
    ((C1FlexGridBase) this.m_flexGrid).FocusRect = (FocusRectEnum) 0;
    ((Control) this.m_flexGrid).Name = "m_flexGrid";
    ((RowColCollection) ((C1FlexGridBase) this.m_flexGrid).Rows).Count = 1;
    ((C1FlexGridBase) this.m_flexGrid).StyleInfo = componentResourceManager.GetString("m_flexGrid.StyleInfo");
    ((C1FlexGridBase) this.m_flexGrid).Tree.Column = 0;
    ((C1FlexGridBase) this.m_flexGrid).AfterScroll += new RangeEventHandler(this.m_flexGrid_AfterScroll);
    ((Control) this.m_flexGrid).Resize += new EventHandler(this.m_flexGrid_Resize);
    ((C1FlexGridBase) this.m_flexGrid).AfterCollapse += new RowColEventHandler(this.m_flexGrid_AfterCollapse);
    ((C1FlexGridBase) this.m_flexGrid).AfterResizeColumn += new RowColEventHandler(this.m_flexGrid_AfterResizeColumn);
    ((Control) this.m_flexGrid).Paint += new PaintEventHandler(this.m_flexGrid_Paint);
    ((Control) this.m_flexGrid).MouseMove += new MouseEventHandler(this.m_flexGrid_MouseMove);
    ((ToolStrip) this.toolStrip1).Items.AddRange(new ToolStripItem[5]
    {
      (ToolStripItem) this.m_toolStripButtonOptions,
      (ToolStripItem) this.m_toolStripButtonDependentJoints,
      (ToolStripItem) this.toolStripSeparator1,
      (ToolStripItem) this.m_toolStripButtonResetToHardLimits,
      (ToolStripItem) this.m_toolStripButtonResetSoftLimits
    });
    componentResourceManager.ApplyResources((object) this.toolStrip1, "toolStrip1");
    ((Control) this.toolStrip1).Name = "toolStrip1";
    ((ToolStripItem) this.m_toolStripButtonOptions).DisplayStyle = ToolStripItemDisplayStyle.Image;
    componentResourceManager.ApplyResources((object) this.m_toolStripButtonOptions, "m_toolStripButtonOptions");
    ((ToolStripItem) this.m_toolStripButtonOptions).Name = "m_toolStripButtonOptions";
    ((ToolStripItem) this.m_toolStripButtonOptions).Click += new EventHandler(this.m_toolStripButtonOptions_Click);
    ((ToolStripItem) this.m_toolStripButtonDependentJoints).DisplayStyle = ToolStripItemDisplayStyle.Image;
    componentResourceManager.ApplyResources((object) this.m_toolStripButtonDependentJoints, "m_toolStripButtonDependentJoints");
    ((ToolStripItem) this.m_toolStripButtonDependentJoints).Name = "m_toolStripButtonDependentJoints";
    ((ToolStripItem) this.m_toolStripButtonDependentJoints).Click += new EventHandler(this.m_toolStripButtonDependentJoints_Click);
    this.toolStripSeparator1.Name = "toolStripSeparator1";
    componentResourceManager.ApplyResources((object) this.toolStripSeparator1, "toolStripSeparator1");
    ((ToolStripItem) this.m_toolStripButtonResetToHardLimits).DisplayStyle = ToolStripItemDisplayStyle.Image;
    componentResourceManager.ApplyResources((object) this.m_toolStripButtonResetToHardLimits, "m_toolStripButtonResetToHardLimits");
    ((ToolStripItem) this.m_toolStripButtonResetToHardLimits).Image = (Image) StringTable.ResetToHardLimits;
    ((ToolStripItem) this.m_toolStripButtonResetToHardLimits).Name = "m_toolStripButtonResetToHardLimits";
    ((ToolStripItem) this.m_toolStripButtonResetToHardLimits).Click += new EventHandler(this.m_toolStripButtonResetToHardLimits_Click);
    ((ToolStripItem) this.m_toolStripButtonResetSoftLimits).DisplayStyle = ToolStripItemDisplayStyle.Image;
    ((ToolStripItem) this.m_toolStripButtonResetSoftLimits).Image = (Image) StringTable.ResetAllSoftLimits;
    componentResourceManager.ApplyResources((object) this.m_toolStripButtonResetSoftLimits, "m_toolStripButtonResetSoftLimits");
    ((ToolStripItem) this.m_toolStripButtonResetSoftLimits).Name = "m_toolStripButtonResetSoftLimits";
    ((ToolStripItem) this.m_toolStripButtonResetSoftLimits).Click += new EventHandler(this.m_toolStripButtonResetSoftLimits_Click);
    componentResourceManager.ApplyResources((object) this.m_buttonReset, "m_buttonReset");
    this.m_buttonReset.Name = "m_buttonReset";
    this.m_buttonReset.UseVisualStyleBackColor = true;
    this.m_buttonReset.Click += new EventHandler(this.m_buttonReset_Click);
    componentResourceManager.ApplyResources((object) this.m_buttonOK, "m_buttonOK");
    this.m_buttonOK.DialogResult = DialogResult.OK;
    this.m_buttonOK.Name = "m_buttonOK";
    this.m_buttonOK.UseVisualStyleBackColor = true;
    this.m_buttonOK.Click += new EventHandler(this.m_buttonApply_Click);
    componentResourceManager.ApplyResources((object) this.m_buttonClose, "m_buttonClose");
    this.m_buttonClose.DialogResult = DialogResult.Cancel;
    this.m_buttonClose.Name = "m_buttonClose";
    this.m_buttonClose.UseVisualStyleBackColor = true;
    this.m_buttonClose.Click += new EventHandler(this.m_buttonClose_Click);
    componentResourceManager.ApplyResources((object) this.m_labelPoseName, "m_labelPoseName");
    this.m_labelPoseName.Name = "m_labelPoseName";
    componentResourceManager.ApplyResources((object) this.m_textBoxPoseName, "m_textBoxPoseName");
    this.m_textBoxPoseName.Name = "m_textBoxPoseName";
    this.m_textBoxPoseName.TextChanged += new EventHandler(this.m_textBoxPoseName_TextChanged);
    ((Form) this).AcceptButton = (IButtonControl) this.m_buttonOK;
    componentResourceManager.ApplyResources((object) this, "$this");
    ((ContainerControl) this).AutoScaleMode = AutoScaleMode.Font;
    ((Control) this).Controls.Add((Control) this.m_textBoxPoseName);
    ((Control) this).Controls.Add((Control) this.m_labelPoseName);
    ((Control) this).Controls.Add((Control) this.m_buttonClose);
    ((Control) this).Controls.Add((Control) this.m_buttonOK);
    ((Control) this).Controls.Add((Control) this.m_buttonReset);
    ((Control) this).Controls.Add((Control) this.toolStrip1);
    ((Control) this).Controls.Add((Control) this.m_flexGrid);
    ((Form) this).MaximizeBox = false;
    ((Form) this).MinimizeBox = false;
    ((Control) this).Name = nameof (CUiKinJointJogForm);
    this.SemiModal = false;
    ((Form) this).SizeGripStyle = SizeGripStyle.Hide;
    ((ISupportInitialize) this.m_flexGrid).EndInit();
    ((Control) this.toolStrip1).ResumeLayout(false);
    ((Control) this.toolStrip1).PerformLayout();
    ((Control) this).ResumeLayout(false);
    ((Control) this).PerformLayout();
  }

  public class CUiKinJointJogColumnData
  {
    private string m_columnName;
    private string m_columnCaption;
    private bool m_visible;

    public CUiKinJointJogColumnData(string name, string caption, bool visible = true)
    {
      this.m_columnName = name;
      this.m_columnCaption = caption;
      this.m_visible = visible;
    }

    public CUiKinJointJogColumnData(CUiKinJointJogForm.CUiKinJointJogColumnData data)
    {
      this.m_columnName = data.m_columnName;
      this.m_columnCaption = data.m_columnCaption;
      this.m_visible = data.m_visible;
    }

    [DisplayName("V")]
    public bool Visible
    {
      get => this.m_visible;
      set => this.m_visible = value;
    }

    [DisplayName("Column")]
    public string ColumnCaption
    {
      get => this.m_columnCaption;
      set => this.m_columnCaption = value;
    }

    public string ColumnName
    {
      get => this.m_columnName;
      set => this.m_columnName = value;
    }

    public override string ToString() => this.m_columnCaption;

    public string SerializeData()
    {
      return $"{$"{string.Empty}{this.m_columnName};"}{this.m_columnCaption};" + this.m_visible.ToString();
    }

    public static CUiKinJointJogForm.CUiKinJointJogColumnData DeserializeString(
      string serializedString)
    {
      string[] strArray = serializedString.Split(';');
      string name = strArray[0];
      string caption = strArray[1];
      bool boolean = Convert.ToBoolean(strArray[2]);
      return new CUiKinJointJogForm.CUiKinJointJogColumnData(name, caption)
      {
        Visible = boolean
      };
    }
  }
}
